#ifndef COMMON_LOG_H
#define COMMON_LOG_H

#pragma GCC diagnostic push

void log_with_format(const char *prefix, const char *function, int line, const char *fmt, ...);

#define LOG_WITH_FORMAT(prefix,format_str, ...) \
log_with_format(prefix, __FUNCTION__, __LINE__, format_str, ##__VA_ARGS__)

#define LOG_CRI(format_str, ...) LOG_WITH_FORMAT("[CRI][", format_str, ##__VA_ARGS__)
#define LOG_ERR(format_str, ...) LOG_WITH_FORMAT("[ERR][", format_str, ##__VA_ARGS__)
#define LOG_WARN(format_str, ...) LOG_WITH_FORMAT("[WARN][", format_str, ##__VA_ARGS__)
#define LOG_INFO(format_str, ...) LOG_WITH_FORMAT("[INFO][", format_str, ##__VA_ARGS__)

#endif
